<?php
namespace app\common\controller;
use think\Controller;
use think\Db;
use think\Request;

/**
 * Class Common 公共控制器
 * @package app\common\controller
 */
class Common extends Controller
{

   public function getContentImg($sourceData){
       foreach($sourceData as $k=>$v){

           $preg = '/<img.+src=\"?(.+\.(jpg|gif|bmp|bnp|png))\"?.+\/>/Ui';//匹配img标签的正则表达式
           preg_match_all($preg, $v['content'], $arr);//这里匹配所有的img
           $res = preg_replace('/("|\')/','',$arr[1]);
           $sourceData[$k]['thumb_path']=$res;
       }
          return $sourceData;
   }
    /***
     * 搜索框控制器
     * @return false|\PDOStatement|string|\think\Collection
     */
   public function searchData(){
      if(Request::instance()->isAjax()){
         $serchData=Request::instance()->post('data');
         $data=Db::table('wb_article')->where('title','like',"%$serchData%")->select();
         return $data;
      };
      if(Request::instance()->param()){
           $serchData=Request::instance()->param();
           dump($serchData) ;
       }else{
          echo 222;
      };
   }

}